import { BasicColumn } from '/@/components/Table/src/types/table';
import { FormSchema } from '/@/components/Table';
import dayjs from 'dayjs';

export function getBasicColumns(): BasicColumn[] {
  return [
    {
      title: '终端类型',
      dataIndex: 'a0',
      width: 80,
      customRender({ record }) {
        if (record.orderSource === '移动端') return 'app';
      },
    },
    {
      title: '预订时间',
      dataIndex: 'a1',
      width: 180,
      customRender({ record }) {
        return dayjs(record.createTime).format('YYYY-MM-DD HH:mm:ss');
      },
    },
    {
      title: '预订人',
      dataIndex: 'a2',
      width: 80,
      customRender({ record }) {
        return record.bookerName;
      },
    },
    {
      title: '出差申请单号',
      dataIndex: 'a3',
      width: 160,
      customRender({ record }) {
        return record.voucherId;
      },
    },
    {
      title: '订单号',
      dataIndex: 'a4',
      width: 190,
      customRender({ record }) {
        return record.orderId;
      },
    },
    {
      title: '12306订单号',
      dataIndex: 'a5',
      width: 120,
      customRender({ record }) {
        return record.idIn12306;
      },
    },
    {
      title: '职工编号',
      dataIndex: 'a6',
      width: 80,
      customRender({ record }) {
        return record.accountNo;
      },
    },
    {
      title: '旅客姓名',
      dataIndex: 'a7',
      width: 80,
      customRender({ record }) {
        return record.empName;
      },
    },
    {
      title: '联系电话',
      dataIndex: 'a8',
      width: 120,
      customRender({ record }) {
        return record.trainOrder.passengers[0].telephone;
      },
    },
    {
      title: '行程',
      dataIndex: 'a9',
      width: 200,
      customRender({ record }) {
        return record.fromStation + '-' + record.arriveStation;
      },
    },
    {
      title: '出发日期',
      dataIndex: 'a10',
      width: 120,
      customRender({ record }) {
        return dayjs(record.fromDate).format('YYYY-MM-DD');
      },
    },
    {
      title: '出发时间',
      dataIndex: 'a11',
      width: 80,
      customRender({ record }) {
        return record.fromTime;
      },
    },
    {
      title: '到达日期',
      dataIndex: 'a12',
      width: 120,
      customRender({ record }) {
        return dayjs(record.arriveDate).format('YYYY-MM-DD');
      },
    },
    {
      title: '到达时间',
      dataIndex: 'a13',
      width: 80,
      customRender({ record }) {
        return record.arriveTime;
      },
    },
    {
      title: '车次',
      dataIndex: 'a14',
      width: 80,
      customRender({ record }) {
        return record.trainCode;
      },
    },
    {
      title: '席别',
      dataIndex: 'a15',
      width: 80,
      customRender({ record }) {
        return record.seatTypeDes;
      },
    },
    {
      title: '座位号',
      dataIndex: 'a16',
      width: 80,
      customRender({ record }) {
        return record.seatNo;
      },
    },
    {
      title: '票价',
      dataIndex: 'a17',
      width: 80,
      customRender({ record }) {
        return record.ticketMoney;
      },
    },
    {
      title: '改签手续费',
      dataIndex: 'a18',
      width: 100,
      customRender({ record }) {
        return record.changeCharge ? record.changeCharge : 0;
      },
    },
    {
      title: '退票手续费',
      dataIndex: 'a19',
      width: 100,
      customRender({ record }) {
        return record.refundCharge ? record.refundCharge : 0;
      },
    },
    {
      title: '线上出票服务费',
      dataIndex: 'a20',
      width: 140,
      customRender({ record }) {
        return record.charge;
      },
    },
    {
      title: '线下出票服务费',
      dataIndex: 'a21',
      width: 140,
      customRender({}) {
        return 0;
      },
    },
    {
      title: '凭证打印费',
      dataIndex: 'a22',
      width: 100,
      customRender({}) {
        return 0;
      },
    },
    {
      title: '售票处服务费',
      dataIndex: 'a23',
      width: 120,
      customRender({}) {
        return 0;
      },
    },
    {
      title: '深白云扣款',
      dataIndex: 'a24',
      width: 100,
      customRender({ record }) {
        return record.ticketMoney + record.charge + record.refundCharge + record.changeCharge;
      },
    },
    {
      title: '应付总计',
      dataIndex: 'a25',
      width: 80,
      customRender({ record }) {
        return record.ticketMoney + record.charge + record.refundCharge + record.changeCharge;
      },
    },
    {
      title: '总金额包含服务费和凭证打印费',
      dataIndex: 'a26',
      width: 160,
      customRender({ record }) {
        return record.ticketMoney + record.charge + record.refundCharge + record.changeCharge;
      },
    },
    {
      title: '订单类别',
      dataIndex: 'a27',
      width: 80,
      customRender({ record }) {
        return record.travelType;
      },
    },
    {
      title: '证件号',
      dataIndex: 'a28',
      width: 180,
      customRender({ record }) {
        return record.trainOrder.passengers[0].certNo;
      },
    },
    {
      title: '客票状态',
      dataIndex: 'a29',
      width: 80,
      customRender({ record }) {
        return record.travelType;
      },
    },
    {
      title: '结算状态',
      dataIndex: 'a30',
      width: 80,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '成本中心',
      dataIndex: 'a31',
      width: 80,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '联系人',
      dataIndex: 'a32',
      width: 80,
      customRender({ record }) {
        return record.trainOrder.linkMans[0].linkManName;
      },
    },
    {
      title: 'DBI信息',
      dataIndex: 'a33',
      width: 80,
      customRender({}) {
        return '-';
      },
    },
    {
      title: 'OA申请单号',
      dataIndex: 'a34',
      width: 160,
      customRender({ record }) {
        return record.voucherId;
      },
    },
    {
      title: '业务经理',
      dataIndex: 'a35',
      width: 80,
      customRender({ record }) {
        return record.busiManage ? record.busiManage : '-';
      },
    },
    {
      title: '原订单号',
      dataIndex: 'a36',
      width: 80,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '是否vip',
      dataIndex: 'a37',
      width: 80,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '提前预订天数',
      dataIndex: 'a38',
      width: 120,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '渠道服务费',
      dataIndex: 'a39',
      width: 100,
      customRender({}) {
        return '0';
      },
    },
    {
      title: '预订人部门',
      dataIndex: 'a40',
      width: 100,
      customRender({ record }) {
        if (record.examineApprove != null) {
          return record.examineApprove.departmentId;
        }
      },
    },
    {
      title: '操作员',
      dataIndex: 'a41',
      width: 80,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '支付方式',
      dataIndex: 'a42',
      width: 80,
      customRender() {
        return '月付';
      },
    },
    {
      title: '个人支付金额',
      dataIndex: 'a43',
      width: 120,
      customRender({}) {
        return 0;
      },
    },
    {
      title: '个人退款金额',
      dataIndex: 'a44',
      width: 120,
      customRender({ record }) {
        return record.refundAmount ? record.refundAmount : 0;
      },
    },
    {
      title: '公司支付金额',
      dataIndex: 'a45',
      width: 120,
      // customRender({ record }) {
      //   return record.ticketMoney + record.charge;
      // },
      customRender({ record }) {
        return record.ticketMoney + record.charge + record.refundCharge + record.changeCharge;
      },
    },
    {
      title: '公司退款金额',
      dataIndex: 'a46',
      width: 120,
      customRender({ record }) {
        return record.refundMoney;
      },
    },
    {
      title: '交易流水号',
      dataIndex: 'a47',
      width: 100,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '费用承担部门',
      dataIndex: 'a48',
      width: 120,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '项目编号',
      dataIndex: 'a49',
      width: 80,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '项目名称',
      dataIndex: 'a50',
      width: 80,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '差旅事项',
      dataIndex: 'a51',
      width: 80,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '超标原因',
      dataIndex: 'a52',
      width: 80,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '超标金额',
      dataIndex: 'a53',
      width: 80,
      customRender({}) {
        return 0;
      },
    },
    {
      title: '超标描述',
      dataIndex: 'a54',
      width: 80,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '费用类型',
      dataIndex: 'a55',
      width: 80,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '差旅授权号',
      dataIndex: 'a56',
      width: 110,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '审批状态',
      dataIndex: 'a57',
      width: 80,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '给审批人留言',
      dataIndex: 'a58',
      width: 120,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '审批组1类型',
      dataIndex: 'a59',
      width: 120,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '审批组1审批人',
      dataIndex: 'a60',
      width: 120,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '审批组2类型',
      dataIndex: 'a61',
      width: 120,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '审批组2审批人',
      dataIndex: 'a62',
      width: 120,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '审批组3类型',
      dataIndex: 'a63',
      width: 120,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '审批组3审批人',
      dataIndex: 'a64',
      width: 120,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '审批组4类型',
      dataIndex: 'a65',
      width: 120,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '审批组4审批人',
      dataIndex: 'a66',
      width: 120,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '员工部门',
      dataIndex: 'a67',
      width: 80,
      customRender({ record }) {
        if (record.examineApprove != null) {
          return record.examineApprove.departmentId;
        }
      },
    },
    {
      title: '原票价',
      dataIndex: 'a68',
      width: 80,
      customRender() {
        return '-';
        // if (record.travelType === '出票单' || record.travelType === '退票单') {
        //   return 0;
        // } else {
        //   return -(
        //     record.trainOrder.passengers[0].ticketMoney +
        //     record.trainOrder.passengers[0].changeCharge +
        //     record.trainOrder.passengers[0].charge +
        //     record.trainOrder.passengers[0].refundMoney
        //   );
        // }
      },
    },
    {
      title: '退改状态',
      dataIndex: 'a69',
      width: 80,
      customRender({ record }) {
        return record.trainOrder.passengers[0].quitStatus
          ? record.trainOrder.passengers[0].quitStatus == 1
            ? '已退'
            : record.trainOrder.passengers[0].quitStatus == 0
            ? '未退'
            : '-'
          : '-';
      },
    },
    {
      title: '改签类型',
      dataIndex: 'a70',
      width: 260,
      customRender({ record }) {
        return record.trainOrder.passengers[0].changeType
          ? record.trainOrder.passengers[0].changeType == 1
            ? '新票款高于原票款，将原单退掉，重新支付新单票款'
            : record.trainOrder.passengers[0].changeType == 2
            ? '新票款与原票款相等，无需支付或退款'
            : record.trainOrder.passengers[0].changeType == 3
            ? '新票款低于原票款，退还差额部分'
            : '-'
          : '-';
      },
    },
    {
      title: '退票时间',
      dataIndex: 'a71',
      width: 150,
      customRender({ record }) {
        return record.refundDate ? record.refundDate : '-';
      },
    },
    {
      title: '退票下单人',
      dataIndex: 'a72',
      width: 100,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '消费记录id',
      dataIndex: 'recordId',
      customRender({ record }) {
        return record.id;
      },
      width: 100,
    },
    // {
    //   title: '订单号',
    //   dataIndex: 'a74',
    //   width: 190,
    //   customRender({ record }) {
    //     return record.orderId;
    //   },
    // },
    {
      title: '乘车人卡号',
      dataIndex: 'a75',
      width: 180,
      customRender({ record }) {
        return record.trainOrder.passengers[0].certNo;
      },
    },
    {
      title: '出发城市',
      dataIndex: 'a76',
      width: 80,
      customRender({ record }) {
        return record.fromStation;
      },
    },
    {
      title: '到达城市',
      dataIndex: 'a77',
      width: 80,
      customRender({ record }) {
        return record.arriveStation;
      },
    },
  ];
}
export const searchFormSchema: FormSchema[] = [
  {
    field: 'outTicketDate',
    component: 'RangePicker',
    label: '出票日期',
    colProps: {
      span: 5,
    },
    componentProps: {
      placeholder: ['出票时间起', '出票时间止'],
      style: 'width:240px',
    },
  },
  {
    field: 'fromDate',
    component: 'RangePicker',
    label: '出发日期',
    colProps: {
      span: 5,
    },
    componentProps: {
      placeholder: ['出发日期起', '出发日期止'],
      style: 'width:240px',
    },
    defaultValue: [getCurrentDataL(), getCurrentDataR()],
  },
  {
    field: 'arriveDate',
    component: 'RangePicker',
    label: '到达日期',
    colProps: {
      span: 5,
    },
    componentProps: {
      placeholder: ['到达日期起', '到达日期止'],
      style: 'width:240px',
    },
  },
  {
    field: 'orderNo',
    label: '订单编号',
    component: 'Input',
    colProps: { span: 4 },
    componentProps: {
      placeholder: ' ',
      style: 'width: 160px',
    },
  },
  {
    field: 'accountNo',
    label: '职工编号',
    component: 'Input',
    colProps: { span: 4 },
    componentProps: {
      placeholder: ' ',
      style: 'width: 160px',
    },
  },
  {
    field: 'empName',
    label: '职工姓名',
    component: 'Input',
    colProps: { span: 5 },
    componentProps: {
      placeholder: ' ',
      style: 'width: 240px',
    },
  },
  {
    field: 'trainCode',
    label: '车次',
    component: 'Input',
    colProps: { span: 5 },
    componentProps: {
      placeholder: ' ',
      style: 'width: 240px',
    },
  },
  {
    field: 'fromStation',
    label: '出发城市',
    component: 'Input',
    colProps: { span: 5 },
    componentProps: {
      placeholder: ' ',
      style: 'width: 240px',
    },
  },
  {
    field: 'arriveStation',
    label: '达到城市',
    component: 'Input',
    colProps: { span: 4 },
    componentProps: {
      placeholder: ' ',
      style: 'width: 160px',
    },
  },
  {
    field: 'seatTypeDes',
    label: '席别',
    component: 'Input',
    colProps: { span: 4 },
    componentProps: {
      placeholder: ' ',
      style: 'width: 160px',
    },
  },
];
//获得当前年份4位年
function getCurrentDataL() {
  return dayjs(dayjs().year().toString() + '-' + Number(dayjs().month()) + '-15').format(
    'YYYY-MM-DD',
  );
}
function getCurrentDataR() {
  // return new Date().toLocaleDateString();
  return dayjs(dayjs().year().toString() + '-' + Number(dayjs().month() + 1) + '-16').format(
    'YYYY-MM-DD',
  );
}
